--[[
	获取提现记录
]]
local filename = "getwithdrawrecord.lua"

local timetool = require "timetool"
local skynet = require "skynet"
local cluster = require "skynet.cluster"
local filelog =require "filelog"

local json = require "cjson"
json.encode_sparse_array(true,1,1)

local service = nil
local CMD = {
	service = nil
}

-- socket传来的请求，可以获取提现记录
function CMD.process(rid, msgbody)
	if not service then
		service = CMD.service
	end

	local recordlist = {}
	local result = cluster.call("datanode", ".router", "select_rk", rid, "rm_withdraw")
    if not result or not result[2] then
        return {withdrawrecords = recordlist}
    end

    local account_type = tonumber(msgbody.account_type) or 0
	for keyid,item in pairs(result[2]) do
        if account_type == 0 or tonumber(item.withdraw_type) == account_type then
            local cur_record = os.date("%Y",tonumber(item.create_time)) .. tostring(item.tradeid) .. "_" .. tostring(item.current_state) .. "_" .. (item.remark or "")
	        table.insert(recordlist, cur_record)
        end
	end

	return {withdrawrecords = recordlist}
end

return CMD
